package com.jeeplus.modules.guide.service;

import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.common.utils.CacheUtils;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.database.datasource.annotation.DS;
import com.jeeplus.modules.guide.entity.MobileAppointment;
import com.jeeplus.modules.guide.entity.MobileUserYYInfo;
import com.jeeplus.modules.guide.mapper.HisQueueMapper;
import com.jeeplus.modules.guide.mapper.MobileAppointmentMapper;
import com.jeeplus.modules.guide.mapper.VersionMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
@DS("queuing")
@RequiredArgsConstructor
@Service
@Transactional(readOnly = true)
public class MobileAppointmentService {
    private final MobileAppointmentMapper mobileAppointmentMapper;
    private static final Logger log = LoggerFactory.getLogger(MobileAppointmentService.class);


    public AjaxJson getAppointmentInfo(String sysno,String cardid) {
        MobileAppointment ma = mobileAppointmentMapper.getAppointmentInfo(sysno,cardid);
        if(null == ma || StringUtils.isBlank(ma.getId())){
            return AjaxJson.error("当前日期时间段暂无此用户预约数据！").put("code","400");
        }else{
            return AjaxJson.success("获取预约数据成功！").put("data",ma);
        }
    }

    @Transactional(readOnly = false)
    public void updateAppointmentInfo(String number,String id,String doTime){
        mobileAppointmentMapper.updateAppointmentInfo(doTime,number,id);
    }
    public HashMap<String,String> getAppointmentInfoById(String id){
        return mobileAppointmentMapper.getAppointmentInfoById(id);
    }

    @Transactional(readOnly = false)
    public void updateYYInfo(){
        mobileAppointmentMapper.updateYYInfo();
    }

//    public void getYYInfo(){
//        List<MobileUserYYInfo> list = mobileAppointmentMapper.getYYUserInfo();
//
//    }

    public String getQueueType(){
        return mobileAppointmentMapper.getQueueType();
    }

  }
